FROM public-cn-beijing.cr.volces.com/public/base:maven-3.6.0-jdk-8-slim as build

# 指定构建过程中的工作目录
WORKDIR /opt/application
# 将当前目录（dockerfile所在目录）下所有文件都拷贝到工作目录下（.dockerignore中文件除外）
COPY . .
COPY src/main/resources /opt/application/resources
COPY src/main/resources/mysql_douyin /opt/application/resources/mysql
COPY src/main/resources/redis_douyin /opt/application/resources/redis

RUN cat /opt/application/resources/redis/game_db-douyin.yml

RUN ls -la /opt/application

RUN ls -la /opt/application/resources

# 拉取公网依赖较慢，容易失败，建议在settings.xml中更换依赖源
RUN mvn -s /opt/application/settings.xml -f /opt/application/pom.xml clean package

RUN ls -la /opt/application

# 容器默认时区为UTC，如需使用上海时间请启用以下时区设置命令
# 复制时区文件
# RUN cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
 
# 设置环境变量（可选）
# ENV TZ=Asia/Shanghai

RUN ln -snf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo "Asia/Shanghai" > /etc/timezone

# 将构建产物jar包拷贝到运行时目录中
RUN chmod -R 777 /opt/application/run.sh

EXPOSE 8000

CMD ["sh","/opt/application/run.sh"]


